package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbPhishing;
import com.ruoyi.system.service.ITbPhishingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钓鱼网站/假冒APP数据填报Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/phishing")
public class TbPhishingController extends BaseController
{
    @Autowired
    private ITbPhishingService tbPhishingService;

    /**
     * 查询钓鱼网站/假冒APP数据填报列表
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbPhishing tbPhishing)
    {
        startPage();
        List<TbPhishing> list = tbPhishingService.selectTbPhishingList(tbPhishing);
        return getDataTable(list);
    }

    /**
     * 导出钓鱼网站/假冒APP数据填报列表
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:export')")
    @Log(title = "钓鱼网站/假冒APP数据填报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPhishing tbPhishing)
    {
        List<TbPhishing> list = tbPhishingService.selectTbPhishingList(tbPhishing);
        ExcelUtil<TbPhishing> util = new ExcelUtil<TbPhishing>(TbPhishing.class);
        util.exportExcel(response, list, "钓鱼网站/假冒APP数据填报数据");
    }

    /**
     * 获取钓鱼网站/假冒APP数据填报详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:query')")
    @GetMapping(value = "/{phishingId}")
    public AjaxResult getInfo(@PathVariable("phishingId") String phishingId)
    {
        return success(tbPhishingService.selectTbPhishingByPhishingId(phishingId));
    }

    /**
     * 新增钓鱼网站/假冒APP数据填报
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:add')")
    @Log(title = "钓鱼网站/假冒APP数据填报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPhishing tbPhishing)
    {

            return toAjax(tbPhishingService.insertTbPhishing(tbPhishing));

    }

    /**
     * 修改钓鱼网站/假冒APP数据填报
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:edit')")
    @Log(title = "钓鱼网站/假冒APP数据填报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPhishing tbPhishing)
    {
        return toAjax(tbPhishingService.updateTbPhishing(tbPhishing));
    }

    /**
     * 删除钓鱼网站/假冒APP数据填报
     */
    @PreAuthorize("@ss.hasPermi('system:phishing:remove')")
    @Log(title = "钓鱼网站/假冒APP数据填报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{phishingIds}")
    public AjaxResult remove(@PathVariable String[] phishingIds)
    {
        return toAjax(tbPhishingService.deleteTbPhishingByPhishingIds(phishingIds));
    }
}
